<?php
use GatewayClient\Gateway;
$keyType = array(
    0 => '不存在',
    1 => '字符串',
    2 => '列表',
    3 => '集合',
    4 => '有序集',
    5 => '哈希表'
);
$keyTitle = array(
    'game_send_grab_params_1' => '抢发包参数 - 五人对战',
    'game_send_grab_params_2' => '抢发包参数 - 牛牛',
    'game_send_grab_params_3' => '抢发包参数 - 扫雷',
    'game_send_grab_params_4' => '抢发包参数 - 二八杠',
    'game_send_grab_params_5' => '抢发包参数 - 10倍牛',
    'game_user_avatar' => '随机头像列表',
    'game_agent_level_list' => '全部代理等级列表',
    'game_list_all' => '有效的游戏列表',
    'game_home_banners' => 'APP与H5的首页轮播',
    'games_sys_config' => 'WEB与H5的系统参数',
    'game_home_banners_1' => 'APP&H5轮播',
    'game_home_banners_4' => 'WEB轮播',
    'sys_paywaysmobile' => 'APP&H5支付通道',
    'sys_paywaysweb' => 'WEB支付通道',
    'games_autosend_userlist' => '机器人列表',
    'chat_Product_Banner' => '商品列表轮播'
);
//$sysConfig = $this->redisGet("games_coinfig_desktop");
//if(!$sysConfig){
    $sql = "SELECT `name`,`title` FROM `@@params`";
    $data = $this->db->query($sql,3);
    foreach ($data as $dk=>$dv){
        $keyTitle['game_sys_paras_'.$dv['name']] = $dv['title'];
    }
    //$this->redisSet("games_coinfig_desktop", $sysConfig);
//}
//chat_products_d5fd0972150be3bd6c9ab248975f8ebc;
/*
$this->pushClient('all', array(
    't'=>'ta',
    'msg' => '推送内容22222推送内容22222推送内容22222推送内容22222推送内容22222',
    'state' => 200,
    'cmd' => 'push',
));
*/
/*
$total=2000;//红包总额
$num=4;// 分成8个红包，支持8人随机领取
$mantissa=0;
$old_total = $total;
mt_srand(time());
$min = ($total / $num / 2) / 100;//每个人最少能收到的金额
if(intval($mantissa)>0) $minrand =  ($mantissa / 100);
if(intval($mantissa)==0) $minrand = mt_rand(1,9) / 100;
$min += $minrand;
if($min < 0.01) $min = 0.01;
$datas = array();
for ($i=1;$i<$num;$i++)
{
    $safe_eg = (float)($num-$i);
    $safe_total=((float)$total-($num-$i)*$min-$minrand)/(float)($safe_eg);//随机安全上限
    // $money=mt_rand($min*100,$safe_total*100)/100;
    $money=random_int($min*100,$safe_total*100)/100;
    $total=$total-$money;
    $datas[$i] = array(
        'coin' => $this->formatCoin($money, 2),
    );
    echo "第{$i}个红包：{$this->formatCoin($money, 2)}元<br />";
}
$datas[$num] = array(
    'coin' => $this->formatCoin($total,2),
);
shuffle($datas);
echo "第{$num}个红包：{$this->formatCoin($total,2)}元<br />";
*/
//$key = array_rand($datas);
//var_dump($key);
//print_r('第'.($i).'个红包：'.$total.' 元，余额：'.$total.' 元 '."\n");
// print_r($datas);
#  列出所有的用户
$userlist = Gateway::getClientSessionsByGroup("public");
array_unique($userlist, SORT_REGULAR);
foreach($userlist as $k=>$v){
    $userlist = $this->array_unset_tt($userlist, 'uid', $v['uid']);
}
$memberOnlineCount = count($userlist);
$userlist = Gateway::getAllClientSessions();
/*
foreach($userlist as $k=>$v) {
    if (isset($v['uid'])) {
        $userlist = $this->array_unset_tt($userlist, 'uid', $v['uid']);
    }
}
*/
?>
<div class="maintop">
	当前位置：桌面 / 系统缓存
    <a action="/cache/update?key=games_sys_config" title="更新WAP缓存" class="mainFrame button icon-undo" href="javascript:;">更新WAP缓存</a>
    <a action="/cache/update?key=all" title="更新缓存" class="mainFrame button icon-undo" href="javascript:;">更新缓存</a>
    <a href="javascript:;" action="/members/onlineuserlist" class="mainFrame button">在线：<?=count($userlist)?></a>
    <a href="javascript:;" action="/members/onlineuserlist?online=public" class="mainFrame button">会员在线：<?=$memberOnlineCount?></a>
    <a href="javascript:;" action="/home/desktop" id="btn_refresh" class="mainFrame button">刷新</a>
</div>
<div class="main-search">
          
</div>
<div id="mainbody">
    <table width="100%" class="tablist">
        <tr class="trbg">
            <th>No.</th>
            <th>键名</th>
            <th>类型</th>
            <th>说明</th>
            <th width="40">操作</th>
        </tr>
        <?php
        # 所有KEY
        $allkeys = $this->redis->keys('*');
        foreach($allkeys as $k=>$v){
            if(false===strpos($v,'games_doing')
                && false===strpos($v,'games_issue')
                && false === strpos($v, 'games_item_for')
                && false === strpos($v, 'game_myuser')
                && false === strpos($v, 'news')
            ){
            ?>
            <tr>
                <td><?=$k?></td>
                <td style="text-align:left"><?=$v?></td>
                <td><?=(isset($keyType[$this->redis->type($v)]) ? $keyType[$this->redis->type($v)] : '') ?></td>
                <td><?=(isset($keyTitle[$v]) ? $keyTitle[$v] : '')?></td>
                <td>
                    <a action="/cache/update?key=<?=$v?>" title="更新" class="mainFrame button icon-undo" href="javascript:;"></a>
                </td>
            </tr>
        <?php } } ?>
    </table>
</div>
</div>
